require('page/common/header/index.js')

var _order_service = require('service/order-service.js');
var ListTempalte = require('./index.string');
var _util = require('util/util.js');
var _order_service = require('service/order-service.js');

var myOrder = {

    MyOrderData: {
        orderList: {},
    },

    init: function () {
        this.bindEvents();
        this.loadOrder()
        return this;
    },


    bindEvents: function () {
        var that = this
        // $('#confirmed').on('click', function () {
        //     that.submit()
        // });

    },
    loadOrder: function () {
        this.getListOrder()
    },

    getListOrder: function () {
        var that = this;
        _order_service.getListOrder(
            function (resp) {
                if (resp.status === 0) {  // 添加状态检查
                    that.MyOrderData.orderList = resp.data;  // 假设后端返回的数据在 resp.data 中
                    var result = _util.renderHtml(ListTempalte, { 
                        MyOrderData: that.MyOrderData 
                    });
                    $('#myOrder1').html(result);
                } else {
                    alert(resp.msg || '获取订单列表失败');
                }
            },
            function (errMsg) {
                alert(errMsg || '获取订单列表失败');
            }
        );
    },

}

module.exports = myOrder.init();